package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CpcEf02;
import com.ruoyi.system.service.ICpcEf02Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Controller
 * 
 * @author ruoyi
 * @date 2025-01-03
 */
@RestController
@RequestMapping("/system/cpc_ef02")
public class CpcEf02Controller extends BaseController
{
    @Autowired
    private ICpcEf02Service cpcEf02Service;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('system:ef02:list')")
    @GetMapping("/list")
    public TableDataInfo list(CpcEf02 cpcEf02)
    {
        startPage();
        List<CpcEf02> list = cpcEf02Service.selectCpcEf02List(cpcEf02);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('system:ef02:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CpcEf02 cpcEf02)
    {
        List<CpcEf02> list = cpcEf02Service.selectCpcEf02List(cpcEf02);
        ExcelUtil<CpcEf02> util = new ExcelUtil<CpcEf02>(CpcEf02.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ef02:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cpcEf02Service.selectCpcEf02ById(id));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('system:ef02:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CpcEf02 cpcEf02)
    {
        return toAjax(cpcEf02Service.insertCpcEf02(cpcEf02));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('system:ef02:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CpcEf02 cpcEf02)
    {
        return toAjax(cpcEf02Service.updateCpcEf02(cpcEf02));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('system:ef02:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cpcEf02Service.deleteCpcEf02ByIds(ids));
    }
}
